#import "PedidoCell.h"

@interface PedidoCell()
@property (weak, nonatomic) IBOutlet UILabel *dataLabel;
@property (weak, nonatomic) IBOutlet UILabel *totalLabel;
@property (weak, nonatomic) IBOutlet UILabel *clienteLabel;

@end

@implementation PedidoCell

@synthesize pedido = _pedido;
@synthesize cliente = _cliente;
@synthesize dataLabel;
@synthesize totalLabel;
@synthesize clienteLabel;

-(void)setPedido:(Pedido *)pedido {
    _pedido = pedido;

    NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"dd/MM/yy"];
    self.dataLabel.text = [dateFormatter stringFromDate:pedido.data];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];
    numberFormatter.currencyDecimalSeparator = @",";
    numberFormatter.currencyGroupingSeparator = @".";
    numberFormatter.currencySymbol = @"R$ ";
    self.totalLabel.text = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:pedido.total]];
}

-(void)setCliente:(Cliente *)cliente {
    _cliente = cliente;
    self.clienteLabel.text = cliente.razaoSocial;
}

@end
